# -*- coding: utf-8 -*-


class BaseMassage:
    def __init__(self, sender, recipient, content, create_time, ip, area, msg_uuid, msg_type='text',
                 is_service=False):
        self.sender = sender
        self.recipient = recipient
        self.content = content
        self.create_time = create_time
        self.ip = ip
        self.area = area
        self.msg_uuid = msg_uuid
        self.msg_type = msg_type
        self.is_service = is_service

    def to_dict(self):
        return {
            'sender': self.sender,
            'recipient': self.recipient,
            'content': self.content,
            'create_time': self.create_time,
            'ip': self.ip,
            'area': self.area,
            'msg_uuid': self.msg_uuid,
            'msg_type': self.msg_type,
            'is_service': self.is_service,
        }


class BaseResult:
    def __init__(self, data: BaseMassage, code=1000, msg='success'):
        self.code = code
        self.msg = msg
        self.data = data

    def to_dict(self):
        return {
            'code': self.code,  ## 0: 成功, -1: 失败
            'msg': self.msg,  ## 已在其他地方登陆
            'data': self.data
        }
